/**
 * Created by Damon on 2016/9/5.
 */
$(window).load(function () {
    //发展历程的时间轴
    //获得在history之前的盒子的高度
    $(".timeline li").attr("bStop", true);
    $(window).scroll(function () {
        var scrollTop = $(document).scrollTop();
        var clientHeirht = $(window).height();
        $(".timeline li").each(function () {
            var top = $(this).offset().top;
            console.log($(this).attr("bStop"));
            if ($(this).attr("bStop")){
                $(this).attr("bStop", false)
                if (scrollTop >= top - clientHeirht / 4 * 3) {
                    if ($(this).hasClass("timeline-l")) {
                        $(this).stop().animate({left: 0, opacity: 1}, 800, "swing", function () {
                            $(this).attr("bStop", true)
                        });
                    } else {
                        $(this).stop().animate({right: 0, opacity: 1}, 800, "swing", function () {
                            $(this).attr("bStop", true)
                        });
                    }
                } else {
                    if ($(this).hasClass("timeline-l")) {
                        $(this).stop().animate({left: "-110%", opacity: 0}, 800, "swing", function () {
                            $(this).attr("bStop", true)
                        });
                    } else {
                        $(this).stop().animate({right: "-110%", opacity: 0}, 800, "swing", function () {
                            $(this).attr("bStop", true)
                        });
                    }
                }
            }

        })
    })
    $(window).scroll(function () {
        var scrollTop = $(document).scrollTop();
        var clientHeirht = $(window).height();
        $(".contact li").each(function () {
            var top = $(".contact").offset().top;
            if (scrollTop >= top - clientHeirht / 4 * 3) {
                $(".contact li").stop().animate({left: 0}, 400)
            } else {
            }
        })
    })
    //当页面滑动到contact时  让图片从两边进来

    //底部contact图片  鼠标移入让图片向上走一段距离
    $(".contact ul li").mouseenter(function () {
        $(this).stop().animate({
            top: "-10px",
            opacity: 1
        }, 200)
    })
    $(".contact ul li").mouseleave(function () {
        $(this).stop().animate({
            top: "0px",
            opacity: 0.5
        }, 200)
    })

})
